This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
WP-r55671: Taxonomy: Always lazily load term meta. #276
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…nclude current object id. The existing lazy loading meta api, creates a queue of ids, to be primed, if the `get_comment_meta` or `get_term_meta` functions are called. However, it did not check to see if the requested id was in the queue, before prime all the ids in the queue. Now, it adds the id to the queue, is not already in the queue, saving a cache lookup / database query. WP:Props spacedmonkey, peterwilsoncc, mukesh27, flixos90. Fixes https://core.trac.wordpress.org/ticket/57901. --- Merges https://core.trac.wordpress.org/changeset/55608 / WordPress/wordpress-develop@7130af403f to ClassicPress.
In https://core.trac.wordpress.org/changeset/34529 introduced lazy loading of term meta. However, this was only in the context of `WP_Query`. Other parts of the codebase, like `WP_Term_Query` did not lazily load term meta. In this change, calls to `update_termmeta_cache` are now replaced with `wp_lazyload_term_meta`, that instead of priming term meta caches, just adds them to the queue to be primed it ever called. This results in far less database queries, as there a number of places where term meta is being primed unnecessarily and never used. Adding everything to the term meta queue, also means that if term meta is used, that is all loaded in a single database / cache call. WP:Props spacedmonkey, mukesh27, peterwilsoncc. Fixes https://core.trac.wordpress.org/ticket/57645. --- Merges https://core.trac.wordpress.org/changeset/55671 / WordPress/wordpress-develop@2c6bf77a9e to ClassicPress.
…sts. Tests: Use the function get_num_queries across all unit tests. Replace use of $wpdb->num_queries with a function call to get_num_queries. This improves readability and consistency between tests. Props SergeyBiryukov, peterwilsoncc, spacedmonkey.
In https://core.trac.wordpress.org/changeset/36566 a framework to lazily load metadata was introduced. This supported term and comment meta by default. In this commit, extends support for site ( blog ) meta. Site meta is not heavily used by core and is used by developers to extend multisite. In this change, `_prime_site_caches` and `WP_Site_Query` now call the new function `wp_lazyload_site_meta`. The function `wp_lazyload_site_meta` accepts an array of ids and adds them to the queue of metadata to be lazily loaded. The function `get_blogs_of_user` was updated to now lazily load site meta. Follow on from https://core.trac.wordpress.org/changeset/55671. WP:Props spacedmonkey, johnjamesjacoby, peterwilsoncc, mukesh27. Fixes https://core.trac.wordpress.org/ticket/58185. --- Merges https://core.trac.wordpress.org/changeset/55747 / WordPress/wordpress-develop@1a5b52a17e to ClassicPress.
…le if class does not exist. Follow on from https://core.trac.wordpress.org/changeset/55747. As `get_sites` can be called very early in the bootstrap process, like in the sunrise.php file, it means that the `WP_Metadata_Lazyloader` may not have been loaded yet in the wp-settings.php file. Add a simple check to see if the class exists and if it does not exist then load the class file in. WP:Props spacedmonkey, peterwilsoncc, dd32. See https://core.trac.wordpress.org/ticket/58185. --- Merges https://core.trac.wordpress.org/changeset/55818 / WordPress/wordpress-develop@ac87b8701f to ClassicPress.
…le if class in meta.php. In https://core.trac.wordpress.org/changeset/55818 did a check to see if `WP_Metadata_Lazyloader` class existed and the loaded in the class file if it did not. However, require in wp-settings.php was not removed and resulted in the class being loaded twice. To be safe, only include the class file in meta.php and remove from wp-settings.php file. WP:Props spacedmonkey, ryelle. See https://core.trac.wordpress.org/ticket/58185. --- Merges https://core.trac.wordpress.org/changeset/55826 / WordPress/wordpress-develop@7d96c1d5f0 to ClassicPress.
xxsimoxx
approved these changes
Nov 2, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
In https://core.trac.wordpress.org/changeset/34270 introduced lazy loading of comment meta. However, this was only in the context of `WP_Query`. Other parts of the codebase, like `WP_Comment_Query` did not lazily load comment meta. In this change, calls to `update_meta_cache` are now replaced with `wp_lazyload_comment_meta`, that instead of priming comment meta caches, just adds them to the queue to be primed it ever called. This results in far less database queries, as there a number of places where comment meta is being primed unnecessarily and never used. Adding everything to the comment meta queue, also means that if comment meta is used, that is all loaded in a single database / cache call. Follow on from https://core.trac.wordpress.org/changeset/55671, https://core.trac.wordpress.org/changeset/55747. WP:Props spacedmonkey, peterwilsoncc, flixos90, mukesh27. Fixes https://core.trac.wordpress.org/ticket/57801. --- Merges https://core.trac.wordpress.org/changeset/55749 / WordPress/wordpress-develop@3114eda235 to ClassicPress.
…yload function. As of https://core.trac.wordpress.org/changeset/55749 wp_queue_comments_for_comment_meta_lazyload is no longer used in core. This commit, deprecates this function. Update docs and tests accordingly. WP:Props sh4lin, spacedmonkey, costdev, peterwilsoncc. Fixes https://core.trac.wordpress.org/ticket/58301. --- Merges https://core.trac.wordpress.org/changeset/55855 / WordPress/wordpress-develop@48683a21fe to ClassicPress.
… function to the correct file. As of https://core.trac.wordpress.org/changeset/55855 wp_queue_comments_for_comment_meta_lazyload was deprecated. But deprecate to wp-admin/deprecated.php and not wp-includes/deprecated.php.This is incorrect, as this is a public function and not an admin function. WP:Props SergeyBiryukov, spacedmonkey. See https://core.trac.wordpress.org/ticket/58301. Conflicts: - src/wp-includes/deprecated.php --- Merges https://core.trac.wordpress.org/changeset/55856 / WordPress/wordpress-develop@69718b2612 to ClassicPress.
Looks good. |
Has two approvals, merging in preparation for v2 repository migration. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Taxonomy: Always lazily load term meta.
In [34529] introduced lazy loading of term meta. However, this was only in the context of WP_Query. Other parts of the codebase, like WP_Term_Query did not lazily load term meta. In this change, calls to update_termmeta_cache are now replaced with wp_lazyload_term_meta, that instead of priming term meta caches, just adds them to the queue to be primed it ever called. This results in far less database queries, as there a number of places where term meta is being primed unnecessarily and never used. Adding everything to the term meta queue, also means that if term meta is used, that is all loaded in a single database / cache call.
Props spacedmonkey, mukesh27, peterwilsoncc.
https://core.trac.wordpress.org/changeset/55671
Motivation and context
Backport of upstream efficiency enhancements
55671 required previous changeset 55608 to be backported. Further changes in changesets 55747 and 55826 are also included and these required 55745 and 55818 respectively.
https://core.trac.wordpress.org/changeset/55608
https://core.trac.wordpress.org/changeset/55671
https://core.trac.wordpress.org/changeset/55745
https://core.trac.wordpress.org/changeset/55747
https://core.trac.wordpress.org/changeset/55749
https://core.trac.wordpress.org/changeset/55818
https://core.trac.wordpress.org/changeset/55826
https://core.trac.wordpress.org/changeset/55855
https://core.trac.wordpress.org/changeset/55856
How has this been tested?
This is a grouped backport, local tests have been passing at each stage.
Screenshots
N/A
Types of changes